window.BASEPATH = "http://localhost:8080";
window.Welcome = {
    startJob: function () {
        $.get(window.BASEPATH + "/job/start", { rd: Math.random() },
            function (response, status, xhr) {
                if (response.suc == true) {
                    alert(response.result);
                } else {
                    alert(response.message);
                }
            }, 'json');

    },
    stopJob: function () {
        $.get(window.BASEPATH + "/job/stop", { rd: Math.random() },
            function (response, status, xhr) {
                if (response.suc == true) {
                    alert(response.result);
                } else {
                    alert(response.message);
                }
            }, 'json');
    },
    statusJob: function () {
        $.get(window.BASEPATH + "/job/status", { rd: Math.random() },
            function (response, status, xhr) {
                if (response.suc == true) {
                    alert(response.result);
                } else {
                    alert(response.message);
                }
            }, 'json');
    },
    serverToken: function () {
        $.get(window.BASEPATH + "/security/token", { rd: Math.random() },
            function (response, status, xhr) {
                $("#txtServerTokenInfo").val(JSON.stringify(response));
            }, 'json');
    },
    localToken: function () {
        $.get(window.BASEPATH + "/security/carrierNo/SF", { rd: Math.random() },
            function (response, status, xhr) {
                $("#txtLocalTokenInfo").val(JSON.stringify(response));
            }, 'json');
    },
    applyToken: function () {
        $.get(window.BASEPATH + "/security/applyToken", { rd: Math.random() },
            function (response, status, xhr) {
                $("#txtApplyTokenInfo").val(JSON.stringify(response));
            }, 'json');
    },
    refreshToken: function () {
        $.get(window.BASEPATH + "/security/refreshToken", { rd: Math.random() },
            function (response, status, xhr) {
                $("#txtRefreshTokenInfo").val(JSON.stringify(response));
            }, 'json');
    },
    downloadPicture: function () {
        var orderNo = $("#txtOrderNo").val();
        if (orderNo != null && orderNo.length > 0) {
            var url = window.BASEPATH + "/waybill/picture/" + orderNo;
            window.open(url, '_blank', 'height=' + $(window).height() + ',width=' + $(window).width() + ',top=0,left=0,titlebar=yes,toolbar=yes,menubar=yes,scrollbars=yes, resizable=no,location=yes, status=yes');
        } else {
            alert("请输入订单编号");
        }
    },
    createOrder: function () {
        var data = $("#txtCreateOrderInfo").val();
        if (data != null && data.length > 0) {
            $.ajax({
                url: window.BASEPATH + "/order",
                type: "POST",
                async: true,
                contentType: "application/json;charset=UTF-8",
                data: data,
                dataType: "json",
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                },
                success: function (data, textStatus, jqXHR) {
                    if (data.suc == true) {
                        alert("创建成功");
                    } else {
                        alert(data.message);
                    }
                }
            });
        } else {
            alert("请填写订单json数据");
        }
    },
    queryOrder: function () {
        var orderNo = $("#txtQueryOrderNo").val();
        if (orderNo != null && orderNo.length > 0) {
            $.get(window.BASEPATH + "/order/" + orderNo, { rd: Math.random() },
                function (response, status, xhr) {
                    $("#txtQueryOrderInfo").val(JSON.stringify(response));
                }, 'json');
        } else {
            alert("请输入订单编号");
        }
    }


}
;